import numpy as np
# from ultralytics import YOLO

#
# def load_model(path):
#     return YOLO(path)
#
#
# def dect(cfg, brt_aoi):
#     model = load_model(cfg['AOI']['model_path'])
#     for color_idx in brt_aoi.color:
#         for gray_idx in range(len(brt_aoi.graylevel)):
#             img = brt_aoi[color_idx][...,gray_idx]
#             pcs_num = img.shape
#             for pcs_idx in range(pcs_num[2]):
#                 img_cut = img[...,pcs_idx]
#                 img_rgb = np.concatenate((img_cut,img_cut,img_cut),axis=2)
#                 results = model(img_rgb)
#                 if len(results[0].boxes.cls)>0:
#                     raise ValueError('缺陷检测存在:'+color_idx+brt_aoi.graylevel(gray_idx))
#     return 0